package com.samsung.sharepoint;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/* This class creates an activity that changes the username
 * which is stored in a shared preferences
 */

public class first extends Activity {
	TextView t1, t2, t3;
	Button b;
	SharedPreferences spref;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.first);

		t1 = (TextView) findViewById(R.id.textView1);
		t3 = (TextView) findViewById(R.id.textView2);
		t3.setText(Html
				.fromHtml("<Font color='#cccccc'><b><i>Enter Your username</i></b></font>"));
		t3.setTextSize(25);
		t1.setText(Html
				.fromHtml("<Font color='#003333'><b>Enter Your Name:</b></font>"));
		t2 = (TextView) findViewById(R.id.editText1);
	}

	public void onStart() {
		super.onStart();
	}

	public void onResume() {
		super.onResume();
		// This button changes the username or saves the preference
		b = (Button) findViewById(R.id.button1);
		b.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				spref = getSharedPreferences("abc", MODE_PRIVATE);
				SharedPreferences.Editor ed = spref.edit();
				ed.putString("name", t2.getText().toString());
				ed.commit();
				Intent intent1 = new Intent(
						"com.samsung.sharepoint.listenservice");
				startService(intent1);
				Intent intent = new Intent(first.this, ChatList.class);
				startActivity(intent);
				finish();
			}
		});
	}

}
